'use strict';function _kw(d,b,c){return(f,a)=>{let e=new Image(b,c);e.onload=function(){f(this)};a&&(e.onerror=function(){a(Error("Failed to load image").add({fullUrl:this.src}))});e.crossOrigin="anonymous";e.src=d}}function _Mp(d,b,c){let f=document.createElement("canvas");f.width=d;f.height=b;if(c){let a=f.getContext("2d");a.fillStyle=c;a.fillRect(0,0,d,b)}return f}function _Xr(d,b="image/png"){return d.toDataURL(b).substr(`data:${b};base64,`.length)}
function _tk(d){let b=document.createElement("dummyTag");b.style.cssText="position: fixed; visibility: hidden; top:0; left:0; padding: 0; border: none";b.style.font=d;b.innerText="a";document.body.appendChild(b);d=b.offsetHeight;b.remove();return d}
function _Ts(d,b,c="black",f){let a=document.createElement("canvas"),e=a.getContext("2d",{willReadFrequently:!0});e.font=b;a.width=e.measureText(d||" ").width;a.height=_tk(b);e.fillStyle=c;e.font=b;e.textBaseline="top";e.fillText(d||" ",0,0,f);return a}
let _4=_wj(function*(d,b){for(var c of b){if(!c)continue;b=_Mp(d.width,d.height);let e=b.getContext("2d");if(c.resize){var f=_Mg(c.resize)?c.resize:(""+c.resize).trim().split(/\s+/);1==f.length&&(f[1]=f[0]);var a=+f[0]||parseFloat(f[0])*b.width/100;f=+f[1]||parseFloat(f[1])*b.height/100;b.width=Math.abs(a);b.height=Math.abs(f);e.scale(a/b.width,f/b.height);e.drawImage(d,0>a?a:0,0>f?f:0,b.width,b.height)}else if(c.rotate)a=c.rotate*Math.PI/180,f=(g,h,k)=>{g%=Math.PI;return 2*Math.sin((g>Math.PI/2?
Math.PI-g:g)+Math.atan2(k/2,h/2))*Math.sqrt(h*h/4+k*k/4)},b.width=f(a,d.height,d.width),b.height=f(a,d.width,d.height),e.translate(b.width/2,b.height/2),e.rotate(a),e.drawImage(d,-d.width/2,-d.height/2);else if(c.background)e.fillStyle=c.background,e.fillRect(0,0,b.width,b.height),e.drawImage(d,0,0);else if(c.margin)a=(""+c.margin).trim().split(/\s+/),1==a.length&&(a[1]=a[0]),2==a.length&&(a[2]=a[0]),3==a.length&&(a[3]=a[1]),b.width+=+a[1]+ +a[3],b.height+=+a[0]+ +a[2],e.drawImage(d,+a[3],+a[0]);
else if(c.shadow)a=c.shadow.trim().split(/\s+/,4),e.shadowOffsetX=+a[0],e.shadowOffsetY=+a[1],e.shadowBlur=+a[2],e.shadowColor=a[3],e.drawImage(d,0,0);else if(c.cornerRadius||c.blendWith)c.cornerRadius&&(c=(""+c.cornerRadius).trim().split(/\s+/),1==c.length&&(c[1]=c[0]),c={blendWith:yield _kw(`data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="${b.width}" height="${b.height}" viewBox="0 0 100 100" `+`preserveAspectRatio="none"><rect x="0" y="0" width="100" height="100" rx="${c[0]}" ry="${c[1]}"/></svg>`),
mode:"destination-in"}),c.blendWith&&(a=(c.mode||"").trim().split(/\s+/),e.drawImage(d,0,0),e.globalCompositeOperation=a[0],e.drawImage(c.blendWith,a[1]||0,a[2]||0));else continue;d=b}return d}),_ta=_wj(function*(d,b,c,f){try{var a=yield _kw(d,b,c)}catch(e){e.fullUrl.startsWith("chrome-extension")&&(yield _Pi(200),a=yield _kw(d,b,c))}d=yield _4(a,[{resize:`${b} ${c}`}]);try{return d.toDataURL(f)}catch(e){return _6p("Canvas toDataURL",{imgUrl:a.src,stack:e.stack}),"data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA="}});
